import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { WalkthroughType } from "./WalkthroughType";
import { ObjCreate } from "../common/ObjCreate";
import { GButton } from "../../../../com/mui/controls/GButton";
import { WalkthroughListWindow } from "./WalkthroughListWindow";
import { Cache } from "../../cache/Cache";
import { EffectManager } from "../../manager/EffectManager";
import { LineBox } from "../guide/LineBox";
import { _levelL } from "../../../../this/_levelL";
import { LevelUp } from "../../../../WalkthroughType/LevelUp";
import { _GrowL } from "../../../../this/_GrowL";
import { Grow } from "../../../../WalkthroughType/Grow";
import { _BoingL } from "../../../../this/_BoingL";
import { Boing } from "../../../../WalkthroughType/Boing";
import { _MoneyL } from "../../../../this/_MoneyL";
import { Money } from "../../../../WalkthroughType/Money";
import { _AccL } from "../../../../this/_AccL";
import { Acc } from "../../../../WalkthroughType/Acc";
type int = number;
//class WalkthroughWindow
    
    export  class WalkthroughWindow extends BaseWindow
    {
        constructor()
        {
            this._levelL = Language.getString(51071);
            this._GrowL = Language.getString(51072);
            this._BoingL = Language.getString(51073);
            this._MoneyL = Language.getString(51074);
            this._AccL = Language.getString(51075);
            this._btnArray = [{"label": _levelL, "type": LevelUp}, {"label": _GrowL, "type": Grow}, {"label": _BoingL, "type": Boing}, {"label": _MoneyL, "type": Money}, {"label": _AccL, "type": Acc}];
            super();
            this.setSize(270, 300);
            this.title = Language.getString(51076);
            this.titleHeight = 28;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            var loc2=null;
            super.createChildren();
            ObjCreate.createBg(17, 39, 235, 250, this);
            var loc3=0;
            while (loc3 < this._btnArray.length) 
            {
                loc2 = this._btnArray[loc3];
                loc1 = ObjCreate.createGButton(loc2.label, 42, 67, 180, 30, this, "ButtonYellow");
                loc1.name = loc2.type + "";
                loc1.y = loc3 * 47 + 57;
                loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
                if (loc3 == 0) 
                {
                    this._levelupBtn = loc1;
                }
                ++loc3;
            }
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=int((arg1.target as GButton).name);
            WalkthroughListWindow.instance.updateByType(loc1);
            WalkthroughListWindow.instance.show();
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            if (Cache.instance.role.entityInfo.level != 36) 
            {
                this.removeLineBox();
            }
            else 
            {
                if (this._secTimer == null) 
                {
                    this._secTimer = new Object /* flash.utils.Timer */(1000);
                    this._secTimer.repeatCount = 8;
                    this._secTimer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.onFlashTimeCompleteHandler);
                }
                this._secTimer.reset();
                this._secTimer.start();
                this._lineBox = EffectManager.getLineBox(185, 35);
                this._lineBox.x = 40;
                this._lineBox.y = 54;
                if (!this.contains(this._lineBox)) 
                {
                    this.addChild(this._lineBox);
                }
            }
            return;
        }

        /* internal  */onFlashTimeCompleteHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            this._secTimer.stop();
            this.removeLineBox();
            return;
        }

        /* internal  */removeLineBox(): void
        {
            if (this._lineBox) 
            {
                if (this.contains(this._lineBox)) 
                {
                    this.removeChild(this._lineBox);
                }
                EffectManager.disposeLineBox(this._lineBox);
            }
            return;
        }

        public static get instance(): WalkthroughWindow
        {
            if (WalkthroughWindow._instance == null) 
            {
                WalkthroughWindow._instance = new WalkthroughWindow();
            }
            return WalkthroughWindow._instance;
        }

        /* internal */ /* var */_lineBox: LineBox;

        /* internal */ /* var */_secTimer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_levelL: string;

        /* internal */ /* var */_GrowL: string;

        /* internal */ /* var */_BoingL: string;

        /* internal */ /* var */_MoneyL: string;

        /* internal */ /* var */_AccL: string;

        /* internal */ /* var */_btnArray: Array<any>;

        /* internal */ /* var */_levelupBtn: GButton;

        /* internal */ static /* var */_instance: WalkthroughWindow;
    }
